#!/bin/bash
# Copyright (c) 2013, Google Inc. Please see the AUTHORS file for details.
# All rights reserved. Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

DART_VER=$(dart --version 2>&1)
if [[ "$DART_VER" != Dart\ VM\ version:* ]] ; then
  echo "Unable to execute dart. Please set the DART_SDK environment variable to"
  echo "the SDK path and add DART_SDK/bin to PATH environment variable. E.g.:"
  echo "  'export DART_SDK=your/path/to/dart/dart-sdk'"
  echo "  'export PATH=\$PATH:\$DART_SDK/bin'";
  exit -1
fi

if [ ! -d "packages" ]; then
  echo "Unable to find dependency pacakges."
  echo "Now running 'pub get'"
  pub get
fi

dart tool/grind.dart $@
